package com.example.delicioushunter.view.adapter;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.example.delicioushunter.R;
import com.example.delicioushunter.model.object.Food;

public class FoodAdapter extends ArrayAdapter<Food> {

	private ArrayList<Food> foods;
	private Context context;

	public FoodAdapter(Context context, ArrayList<Food> foods) {
		super(context, R.layout.row_food, foods);
		this.context = context;
		this.foods = foods;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		LayoutInflater inflater = (LayoutInflater) context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		View rowView = inflater.inflate(R.layout.row_food, parent, false);
		RelativeLayout layoutFood = (RelativeLayout) rowView.findViewById(R.id.layoutFood);
		ImageView imgFood = (ImageView) rowView.findViewById(R.id.imgFood);
		TextView txtFoodName = (TextView) rowView.findViewById(R.id.txtFoodName);
		ImageView imgAvatar= (ImageView) rowView.findViewById(R.id.imgAvatar);
		TextView txtName = (TextView) rowView.findViewById(R.id.txtName);

		Food food = foods.get(position);
		
		imgFood.setImageBitmap(food.getThumb());
		txtFoodName.setText(food.getName());
		return rowView;
	}

}
